package com.charles.video.api.feignFallBack;

import com.charles.video.api.domain.SysMember;
import com.charles.video.api.feignService.RemoteMemberService;
import com.charles.video.api.model.MemberLogin;
import com.charles.video.common.core.responseDomain.R;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @author Charles-H
 * 
 * 用户服务降级处理
 */
@Component
public class RemoteMemberFallbackFactory implements FallbackFactory<RemoteMemberService> {

    private static final Logger log = LoggerFactory.getLogger(RemoteMemberFallbackFactory.class);

    @Override
    public RemoteMemberService create(Throwable cause) {
        log.error("成员服务调用失败:{}", cause.getMessage());
        return new RemoteMemberService() {
            @Override
            public R<MemberLogin> getMemberInfo(String memberNum, String source) {
                return R.fail("获取成员信息失败:" + cause.getMessage());
            }

            @Override
            public void recordLoginTime(SysMember sysMember, String source) {
            }
        };
    }

}
